import { IManagement } from "@/api";
import { Badge, DescriptionsItemProps } from "@/components";
import { RATE_LIST } from "@/constants";
import { Space } from "antd";

export const getLeftItems = (
  record: IManagement.ResManagementItemCheck
): Array<DescriptionsItemProps> => [
  {
    label: "任务名称",
    children: record.name,
  },
  {
    label: "创建时间",
    children: record.createTime,
  },
  {
    label: "任务描述",
    children: record.desc,
  },
  {
    label: "任务状态",
    children:
      record.state === 1 ? (
        <span style={{ color: "#52C41A" }}>正常</span>
      ) : (
        <span style={{ color: "#FF4D4F" }}>已停用</span>
      ),
  },
];

export const getRightItems = (
  record: IManagement.ResManagementItemCheck
): Array<DescriptionsItemProps> => [
  {
    label: "上报间隔",
    children: `${record.cycle}${
      RATE_LIST.find((item) => item.value === record.rate)?.label
    }`,
  },
  {
    label: "上报数据",
    children: (
      <Space direction="vertical">
        <Badge
          color="#1677ff"
          text={
            <span style={{ color: "#1677ff" }}>
              总量：{record.reportCount}
            </span>
          }
        />
        <Badge
          status="success"
          text={
            <span style={{ color: "#52C41A" }}>
              成功：{record.successCount}
            </span>
          }
        />
        <Badge
          status="error"
          text={
            <span style={{ color: "#FF4D4F" }}>
              失败：{record.failCount}
            </span>
          }
        />
      </Space>
    ),
  },
];
